<?php
/**
 * Created by PhpStorm.
 * User: zeopean
 * Date: 2015/8/8
 * Time: 10:48
 */
namespace App\Exceptions;

use Exception;

class UserTeamsFillException extends Exception
{
    /**
     * NoRealName       表示用户名不存在，应该填写
     * RealNameExists   表示该用户名不可用
     * WechatExists     表示用户的微信不可用
     * WeiboExistst     表示微博不可用
     * MaimaiExists     表示脉脉不可用
     */
    const NoRealName = 0x01;
    const RealNameExists = 0x02;
    const WechatExists = 0x03;
    const WeiboExists = 0x04;
    const MaimaiExists = 0x05;

    public function __construct($code, array $data = [], Exception $previous = null)
    {
        switch ($code) {
            case self::NoRealName:
                $message = trans('exception.user_teams_fill.no_realname', ['realname' => array_get($data,  'realname')]);
                break;
            case self::RealNameExists:
                $message = trans('exception.user_teams_fill.realname_exists', ['realname' => array_get($data,  'realname')]);
                break;
            case self::WechatExists:
                $message = trans('exception.user_teams_fill.wechat_exists', ['wechat' => array_get($data, 'wechat')]);
                break;
            case self::WeiboExists:
                $message = trans('exception.user_teams_fill.weibo_exists', ['weibo' => array_get($data, 'weibo')]);
                break;
            case self::MaimaiExists:
                $message = trans('exception.user_teams_fill.maimai_exists', ['maimai' => array_get($data,'maimai')]);
                break;
            default:
                $message = trans('general.unknown_exception');
                break;
        }

        parent::__construct($message, $code, $previous);
    }
}